{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "fb4486e7",
   "metadata": {},
   "source": [
    "### STAR fusion RNA IDs \n",
    "\n",
    "* Run all RNA IDs with misexpressed gene that has misexpression-associated SV in cis "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "bf679b76",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd \n",
    "from pathlib import Path "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "b9fa377b",
   "metadata": {},
   "outputs": [],
   "source": [
    "wkdir = \"/lustre/scratch126/humgen/projects/interval_rna/interval_rna_seq/thomasVDS/misexpression_v3\"\n",
    "wkdir_path = Path(wkdir)\n",
    "# input files \n",
    "misexp_vrnt_feat_path = wkdir_path.joinpath(\"6_misexp_dissect/vrnt_features/misexp_vrnt_features.tsv\")\n",
    "\n",
    "# output\n",
    "out_dir=wkdir_path.joinpath(\"6_misexp_dissect/star_fusion/\")\n",
    "out_dir_path = Path(out_dir)\n",
    "out_dir_path.mkdir(parents=True, exist_ok=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "f2e28619",
   "metadata": {},
   "outputs": [],
   "source": [
    "misexp_vrnt_feat_df = pd.read_csv(misexp_vrnt_feat_path, sep=\"\\t\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "4b163483",
   "metadata": {},
   "outputs": [],
   "source": [
    "rna_ids_misexp_vrnt = misexp_vrnt_feat_df.rna_id.unique()\n",
    "star_fusion_rna_ids_path = out_dir_path.joinpath(\"star_fusion_rna_ids.txt\")\n",
    "with open(star_fusion_rna_ids_path, \"w\") as f_out: \n",
    "    for rna_id in rna_ids_misexp_vrnt: \n",
    "        f_out.write(f\"{rna_id}\\n\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "96c049b8",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Number of RNA IDs: 92\n"
     ]
    }
   ],
   "source": [
    "print(f\"Number of RNA IDs: {len(rna_ids_misexp_vrnt)}\")"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
